package com.yrmao.chiefenergyofficer.ui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.yrmao.chiefenergyofficer.R;
import com.yrmao.chiefenergyofficer.ui.common.BaseFragment;

/**
 * Created by sikong on 16/11/15.
 */

public class MainFragment extends BaseFragment {
    private View contentView;
    private ItemCarouselFragment mItemCarouselFragment;
    private ItemCenterFragment mItemCenterFragment;
    private ItemContentFragment mItemContentFragment;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        contentView = LayoutInflater.from(getActivity()).inflate(R.layout.frag_main, null);
        initFragment();
    }

    private void initFragment() {
        mItemCarouselFragment = new ItemCarouselFragment();
        mItemCenterFragment = new ItemCenterFragment();
        mItemContentFragment = new ItemContentFragment();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return contentView;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initToFragment();
    }

    private void initToFragment() {
        getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fl_main_top, mItemCarouselFragment).commit();
        getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fl_main_center, mItemCenterFragment).commit();
        getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fl_main_bottom, mItemContentFragment).commit();

    }
}
